"""
URL class
"""

class URLError(Exception):
    pass

class URL(object):

    @classmethod
    def from_template(cls, url):
        return cls(url=url)

    def __init__(self, url):
        self.url = url
        self.items = None

    def create_many(self, params):
        self.items = ( self.url.format(**p) for p in params )
        return self.items

    def create(self, **param):
        return self.url.format(**param)

    def get(self, **param):
        return self.url.format(**param)

    def __iter__(self):
        return self.items
